package com.wjy.rbac.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wjy.rbac.entity.RolePower;
import com.wjy.rbac.mapper.RolePowerMapper;
import com.wjy.rbac.service.IRolePowerService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ybxxszl
 * @since 2019-04-12
 */
@Service
public class RolePowerServiceImpl extends ServiceImpl<RolePowerMapper, RolePower> implements IRolePowerService {

    @Override
    public void insert(RolePower rolePower) {
        save(rolePower);
    }

    @Override
    public void update(RolePower rolePower) {
        updateById(rolePower);
    }

    @Override
    public void delete(String rolePowerId) {
        removeById(rolePowerId);
    }

    @Override
    public Map<String, Object> get(String rolePowerId) {
        Map<String, Object> map = new HashMap<String, Object>();
        RolePower rolePower = getById(rolePowerId);
        map.put("rolePower", rolePower);
        return map;
    }

    @Override
    public List<RolePower> getByRoleId(String roleId) {
        Map<String, Object> columnMap = new HashMap<String, Object>();
        columnMap.put(RolePower.ROLE_ID, roleId);
        List<RolePower> rolePowerList = (List<RolePower>) listByMap(columnMap);
        return rolePowerList;
    }

}
